//
//  CAMoneyTableViewCell.m
//  LNH
//
//  Created by twentylx on 2018/1/22.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CAMoneyTableViewCell.h"

@implementation CAMoneyTableViewCell

- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addSubview:self.titleLabel];
        [self addSubview:self.dateLabel];
        [self addSubview:self.moneyLabel];
        [self addSubview:self.lineView];
        
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(20);
            make.top.equalTo(self).offset(25);
        }];
        
        [_dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.titleLabel);
            make.top.equalTo(self.titleLabel.mas_bottom).offset(10);
        }];
        
        [_moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-30);
            make.centerY.equalTo(self);
        }];
        
        [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.and.right.equalTo(self);
            make.bottom.equalTo(self);
            make.height.mas_equalTo(ONE_PIXEL);
        }];
    }
    return self;
}

#pragma mark get & set
- (UILabel *) titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.text = @"订单12312312312";
        _titleLabel.font = [UIFont systemFontOfSize:16];
    }
    return _titleLabel;
}

- (UILabel *) dateLabel {
    if (!_dateLabel) {
        _dateLabel = [UILabel new];
        _dateLabel.text = @"2018/1/1 18:00:00";
        _dateLabel.font = [UIFont systemFontOfSize:16];
        _dateLabel.textColor = RGBCOLOR(128, 128, 128);
    }
    return _dateLabel;
}

- (UILabel *) moneyLabel {
    if (!_moneyLabel) {
        _moneyLabel = [UILabel new];
        _moneyLabel.text = @"+10";
        _moneyLabel.font = [UIFont systemFontOfSize:20];
        _moneyLabel.textColor = RGBCOLOR(240, 90, 36);
        _moneyLabel.textAlignment = NSTextAlignmentRight;
    }
    return _moneyLabel;
}

- (UIView *) lineView {
    if (!_lineView) {
        _lineView = [UIView new];
        _lineView.backgroundColor = RGBCOLOR(241, 241, 241);
    }
    return _lineView;
}


#pragma mark system func
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
